<template>
	<div class="quanXian center align-start fWrap">
		<div class="right bfff left-bumen">
			<div class="title">
				<div
					class="c666 f14 hover title-left"
					:class="{ ctheme: i == navIndex }"
					v-for="(v, i) in nav"
					@click="navList(v, i)"
				>
					{{ v }}
				</div>
			</div>
		</div>
		<div class="nav-dis" @click="drawer = true">标签</div>
		<el-drawer v-model="drawer" size="40%" :with-header="false">
			<div class="title">
				<div
					class="c666 f16 hover title-left"
					:class="{ ctheme: i == navIndex }"
					v-for="(v, i) in nav"
					@click="navList(v, i)"
				>
					{{ v }}
				</div>
			</div>
		</el-drawer>
		<div class="left flex" v-if="classification || navIndex != '0'">
			<div class="bfff left-bottom">
				<div class="center flex-start table-head3 fWrap">
					<div class="c666 f14">标签：</div>
					<div>
						<el-input
							type="text"
							placeholder="请输入标签..."
							v-model="labelName"
							@keyup.enter.native="onSearch"
						/>
					</div>
					<div class="box-button-top">
						<el-button class="primary" type="primary" @click="onSearch">搜索</el-button>
						<el-button type="primary" plain @click="resetting">重置</el-button>
					</div>
				</div>
				<div class="center flex-start fWrap table-head">
					<el-button
						class="primary"
						v-auth="['knowledge:kbModelLabel:save', 'knowledge:kbLabelCategory:save']"
						type="primary"
						@click="add"
						v-if="navIndex == '0'"
					>
						+ 新增
					</el-button>
					<!-- <el-button
						class="primary"
						v-auth="['knowledge:kbModelLabel:edit']"
						:type="navIndex == '2' ? 'success' : ''"
						@click="efficacy('2')"
						plain
						v-if="navIndex == '2'"
						>置为生效</el-button
					> -->
					<el-button
						class="danger"
						type="warning"
						v-auth="[
							'knowledge:kbModelLabel:edit',
							'knowledge:kbLabelCategory:deleteBatch',
							'knowledge:kbLabelCategory:delete',
						]"
						@click="efficacy('1')"
						v-if="navIndex != '2'"
						plain
						>置为失效</el-button
					>
					<div v-if="navIndex == '2'">
						<el-button
							class="primary"
							v-auth="['knowledge:kbModelLabel:deleteBatch', 'knowledge:kbLabelCategory:deleteBatch']"
							type="danger"
							@click="delTags"
							plain
							>批量删除</el-button
						>
					</div>
					<el-button class="danger-del" type="success" @click="returnClassify" plain v-if="navIndex == '0'">
						返回
					</el-button>
				</div>
				<div class="alert">
					<el-alert title="失效标签不可恢复" type="error" show-icon />
				</div>
				<div class="center table-head2">
					<div class="f14 choice-num flex ctheme">已选：{{ selectList.length }}</div>
				</div>
				<div class="table-scrol">
					<div class="table">
						<el-table
							@select="selectClick"
							@select-all="selectAllClick"
							:data="tableData"
							style="width: 100%"
						>
							<el-table-column align="center" type="selection" min-width="60" />
							<el-table-column
								align="center"
								prop="name"
								label="标签名称"
								show-overflow-tooltip
								min-width="150"
							/>
							<el-table-column
								align="center"
								prop="count"
								label="使用次数"
								v-if="navIndex != '2'"
								show-overflow-tooltip
								min-width="150"
							/>
							<el-table-column
								align="center"
								prop="sort"
								label="权重"
								v-if="navIndex == '0'"
								show-overflow-tooltip
								min-width="150"
							/>
							<el-table-column
								align="center"
								prop="count"
								v-if="navIndex == '2'"
								label="所属类型"
								show-overflow-tooltip
								min-width="150"
							>
								<template #default="{ row }">
									<el-text v-if="row.status == '1'" type="warning">机器</el-text>
									<el-text v-else type="success">系统</el-text>
									<!-- <div v-else>机器</div> -->
								</template>
							</el-table-column>
							<el-table-column align="center" label="状态" show-overflow-tooltip min-width="150">
								<template #default="{ row }">
									<!-- <el-button type="text" v-if="row.isDeletedd == 2" @click="takeEffect(row, 1)"
										>生效</el-button
									>
									<el-button type="text" v-else @click="takeEffect(row, 2)">未生效</el-button> -->
									<el-text type="warning" v-if="navIndex == '2'">失效</el-text>
									<el-text type="success" v-else>生效</el-text>
								</template>
							</el-table-column>
							<el-table-column
								align="center"
								v-if="navIndex != '2'"
								label="热词"
								show-overflow-tooltip
								min-width="150"
							>
								<template #default="{ row }">
									<el-button type="success" plain v-if="row.hotWord == 1" @click="hot(row, 2)">
										热&nbsp;&nbsp;&nbsp;词
									</el-button>
									<el-button type="warning" plain v-else @click="hot(row, 1)">非热词</el-button>
								</template>
							</el-table-column>
							<el-table-column
								align="center"
								label="操作"
								v-if="navIndex == '2' || navIndex == '0'"
								show-overflow-tooltip
								min-width="150"
							>
								<template #default="{ row }">
									<div class="table-color" v-if="navIndex == '2'">
										<el-button
											:icon="Delete"
											@click="delTag(row)"
											v-auth="[
												'knowledge:kbModelLabel:delete',
												'knowledge:kbLabelCategory:delete',
											]"
										></el-button>
									</div>
									<div class="table-color" v-if="navIndex == '0'">
										<el-button
											:icon="EditPen"
											v-auth="['knowledge:kbModelLabel:edit']"
											@click="tagWeight(row)"
										></el-button>
									</div>
								</template>
							</el-table-column>
							<template #empty>
								<el-empty description="暂无数据" />
							</template>
						</el-table>
						<br />
						<div style="display: flex; justify-content: center">
							<v-pagination
								:total="total"
								v-model:size="pageSize"
								v-model:page="current"
								@pagination="fetchListStr"
								@paginations="fetchListStr"
							></v-pagination>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="left flex" v-else>
			<div class="bfff left-bottom">
				<div class="center flex-start table-head3 fWrap">
					<div class="c666 f14">标签分类：</div>
					<div>
						<el-input
							type="text"
							placeholder="请输入标签分类..."
							v-model="labelName"
							@keyup.enter.native="onSearch"
						/>
					</div>
					<div style="margin-left: 7px">
						<el-input
							type="text"
							placeholder="请输入标签名称..."
							v-model="search.labelName"
							@keyup.enter.native="onSearch"
						/>
					</div>
					<div class="box-button-top">
						<el-button class="primary" type="primary" @click="onSearch">搜索</el-button>
						<el-button type="primary" plain @click="resetting">重置</el-button>
					</div>
				</div>
				<div class="center flex-start fWrap table-head">
					<el-button
						class="primary primaryW"
						v-auth="['knowledge:kbLabelCategory:save']"
						type="primary"
						@click="addClassification"
						>+ 新增标签分类</el-button
					>
					<el-button
						class="primary"
						type="danger"
						@click="delTags"
						v-auth="['knowledge:kbModelLabel:deleteBatch', 'knowledge:kbLabelCategory:deleteBatch']"
						plain
						>批量删除</el-button
					>
				</div>
				<div class="center table-head2">
					<div class="f14 choice-num flex ctheme">已选：{{ selectList.length }}</div>
				</div>
				<div class="table-scrol">
					<div class="table">
						<el-table
							:data="tableData"
							style="width: 100%"
							@select="selectClick"
							@select-all="selectAllClick"
						>
							<el-table-column align="center" type="selection" min-width="60" />
							<el-table-column
								align="center"
								prop="name"
								label="标签分类名称"
								show-overflow-tooltip
								min-width="180"
							>
								<template #default="{ row }">
									<el-button link type="primary" @click="clickClassify(row)"
										>{{ row.name }}&nbsp;></el-button
									>
								</template>
							</el-table-column>
							<!-- <el-table-column align="center" label="状态" show-overflow-tooltip min-width="150">
								<template #default="{ row }">
									<el-text type="warning" v-if="row.isDeleted == 1">失效</el-text>
									<el-text type="success" v-else>生效</el-text>
								</template>
							</el-table-column> -->
							<el-table-column align="center" label="创建时间" show-overflow-tooltip min-width="150">
								<template #default="{ row }">
									<div>{{ row.createTime.substring(0, 10) }}</div>
								</template>
							</el-table-column>
							<el-table-column align="center" label="操作" show-overflow-tooltip min-width="150">
								<template #default="{ row }">
									<div class="table-color">
										<el-button
											:icon="EditPen"
											@click="editClassification(row)"
											v-auth="[
												'knowledge:kbLabelCategory:edit',
												'knowledge:kbLabelCategory:info',
												'knowledge:kbLabelCategory:pageList',
											]"
										></el-button>
										<el-button
											:icon="Delete"
											@click="delClassification(row)"
											v-auth="[
												'knowledge:kbModelLabel:delete',
												'knowledge:kbLabelCategory:delete',
											]"
										></el-button>
									</div>
								</template>
							</el-table-column>
							<template #empty>
								<el-empty description="暂无数据" />
							</template>
						</el-table>
						<br />
						<div style="display: flex; justify-content: center">
							<v-pagination
								:total="total"
								v-model:size="pageSize"
								v-model:page="current"
								@pagination="fetchListStr"
								@paginations="fetchListStr"
							></v-pagination>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 新增标签 -->
		<el-dialog
			class="cheng-dialog"
			v-model="visible"
			:show-close="false"
			:close-on-click-modal="false"
			:destroy-on-close="true"
			width="800px"
		>
			<template #header>
				<div class="dialog-header center btheme cfff">
					<img src="@/assets/image/houTai/biao.png" alt="" />
					<div class="flex f16 fbold">{{ visibleListTitle }}</div>
					<el-icon class="pointer" size="20" color="#fff" @click="closes">
						<Close />
					</el-icon>
				</div>
			</template>
			<div class="dialog-content">
				<el-form ref="ruleFormRef" :model="ruleForm" class="demo-ruleForm" :size="formSize" status-icon>
					<div class="center" v-for="(v, i) in visibleList">
						<div class="flex">
							<el-form-item label="标签名称" prop="name">
								<el-input
									class="name"
									v-model="v.name"
									placeholder="请输入标签名称"
									:maxlength="15"
									:disabled="!tagWeightIf"
								/>
							</el-form-item>
						</div>
						<div>
							<el-form-item label="权重" prop="sort">
								<template #label>
									<div>权重</div>
									<el-tooltip
										class="box-item"
										effect="dark"
										content="数字越大越靠前"
										placement="top"
										:offset="0"
									>
										<el-icon class="label-icon"><InfoFilled /></el-icon>
									</el-tooltip>
								</template>
								<template #default>
									<el-input-number v-model="v.sort" :min="1" />
								</template>
							</el-form-item>
						</div>
						<div class="icon pointer">
							<el-icon @click="removeList(i)" size="18" color="#2972FA" v-if="i != 0">
								<CircleCloseFilled />
							</el-icon>
						</div>
					</div>
					<el-form-item label="" v-if="tagWeightIf">
						<div class="center">
							<div class="el-form-item__label"></div>
							<el-button @click="addList()" type="primary" plain :icon="CirclePlusFilled" class="flex">
								新增一条
							</el-button>
						</div>
					</el-form-item>
				</el-form>
			</div>
			<template #footer>
				<div class="dialog-footer">
					<el-button @click="closes">取消</el-button>
					<el-button type="primary" @click="sub"> 确定 </el-button>
				</div>
			</template>
		</el-dialog>
		<!-- 新增标签分类 -->
		<el-dialog
			class="cheng-dialog"
			v-model="visibleClassification"
			:show-close="false"
			:before-close="closes"
			:close-on-click-modal="false"
			destroy-on-close
			width="800px"
		>
			<template #header="{ close, titleId, titleClass }">
				<div class="dialog-header center btheme cfff">
					<img src="@/assets/image/houTai/biao.png" alt="" />
					<div class="flex f16 fbold">{{ classificationTitle }}</div>
					<el-icon class="pointer" size="20" color="#fff" @click="closes">
						<Close />
					</el-icon>
				</div>
			</template>
			<div class="dialog-content">
				<el-form :model="ruleFormClassificationList" class="demo-ruleForm" status-icon>
					<div class="center" v-for="(v, i) in visibleClassificationList">
						<div class="flex">
							<el-form-item label="标签分类名称" prop="name">
								<el-input
									class="name"
									v-model="v.name"
									placeholder="请输入标签分类名称"
									maxlength="20"
									show-word-limit
								/>
							</el-form-item>
						</div>
						<div class="icon pointer">
							<el-icon @click="removeListClassification(i)" size="18" color="#2972FA" v-if="i != 0">
								<CircleCloseFilled />
							</el-icon>
						</div>
					</div>

					<el-form-item label="" v-if="classificationTitle != '编辑标签分类'">
						<div class="center">
							<div class="el-form-item__label"></div>
							<el-button
								@click="addClassificationList()"
								type="primary"
								plain
								:icon="CirclePlusFilled"
								class="flex"
								>新增一条</el-button
							>
						</div>
					</el-form-item>
				</el-form>
			</div>
			<template #footer>
				<div class="dialog-footer">
					<el-button @click="closes">取消</el-button>
					<el-button type="primary" @click="subClassificationList"> 确定 </el-button>
				</div>
			</template>
		</el-dialog>
	</div>
</template>

<script setup>
import { CirclePlusFilled, Delete, EditPen } from "@element-plus/icons-vue"
import { ElMessage, ElMessageBox } from "element-plus"

// 左侧菜单栏
const nav = ref(["系统标签", "机器标签", "失效标签"])
const navIndex = ref(0)
const total = ref(0)
const status = ref(2)
const current = ref(1)
const pageSize = ref(10)
const drawer = ref(false)
const visibleListTitle = ref("")
const tagWeightIf = ref(true)
const classificationTitle = ref("")
const fabu = ref(false)
const classification = ref(false)
const search = reactive({
	labelName: "",
})
// 新增标签
const visibleList = ref([
	{
		name: "",
		sort: 1,
		status: status.value,
	},
])
// 新增标签分类
const visibleClassificationList = ref([
	{
		name: "",
	},
])
const selectList = ref([])
const removeList = index => {
	visibleList.value.splice(index, 1)
}
const removeListClassification = index => {
	visibleClassificationList.value.splice(index, 1)
}
const addList = () => {
	if (visibleList.value.length < 10) {
		visibleList.value.push({
			name: "",
			sort: 1,
			status: status.value,
		})
	} else {
		ElMessage.error("标签最多添加10条")
	}
}
const addClassificationList = () => {
	if (visibleClassificationList.value.length < 10) {
		visibleClassificationList.value.push({
			name: "",
		})
	} else {
		ElMessage.error("一次最多只能增加10条")
	}
}
const visible = ref(false)
const visibleClassification = ref(false)
const ruleForm = reactive({
	region: "",
	num: 1,
	bumen: [],
})
const ruleFormClassificationList = reactive({
	region: "",
})
const labelName = ref("")

const tableData = ref([])

const closes = () => {
	visible.value = false
	visibleClassification.value = false
	visibleList.value = [
		{
			name: "",
			sort: 1,
			status: status.value,
		},
	]
	visibleClassificationList.value = [
		{
			name: "",
		},
	]
}
//用户点击勾选
const selectClick = row => {
	selectList.value = row
}
//用户点击全选
const selectAllClick = row => {
	selectList.value = row
}
const navList = async (item, index) => {
	current.value = 1
	selectList.value = []
	labelName.value = ""
	navIndex.value = index
	classification.value = false
	current.value = 1
	pageSize.value = 10
	switch (index) {
		case 0:
			status.value = 2
			break
		case 1:
			status.value = 1
			break
		case 2:
			status.value = 3
			break
	}
	if (navIndex.value != 0) {
		getModelLabel()
	} else {
		const res = await getAxios(`/knowledge/kbLabelCategory/page?current=${current.value}&size=${pageSize.value}`)
		total.value = +res.total
		tableData.value = res.records
	}
}
async function lableList() {
	const res = await getAxios(`/knowledge/kbLabelCategory/page`, {
		current: current.value,
		size: pageSize.value,
		name: labelName.value,
		labelName: search.labelName,
	})
	total.value = +res.total
	tableData.value = res.records
}
lableList()
const onSearch = async () => {
	if (navIndex.value == 0 && !classification.value) {
		const res = await getAxios(
			`/knowledge/kbLabelCategory/page?current=${current.value}&size=${pageSize.value}&name=${labelName.value}&labelName=${search.labelName}`
		)
		total.value = +res.total
		tableData.value = res.records
	} else if (navIndex.value == 0 && classification.value) {
		const res = await getAxios(
			`/knowledge/kbLabelCategory/showLabel?ctId=${classifyId.value}&current=1&size=${pageSize.value}&name=${labelName.value}`
		)
		total.value = +res.total
		tableData.value = res.records
	} else {
		selectList.value = []
		if (navIndex.value == 1) {
			status.value = 1
		} else if (navIndex.value == 2) {
			status.value = 3
		}
		current.value = 1
		let obj = {}
		obj.current = current.value
		if (status.value == 3) {
			obj.isDeleted = 1
		} else {
			obj.status = status.value
		}
		obj.name = labelName.value
		const res = await getAxios(`/knowledge/kbModelLabel/page`, obj)
		total.value = +res.total
		tableData.value = res.records
	}
}
async function fetchListStr() {
	selectList.value = []
	if (navIndex.value == 0 && !classification.value) {
		const res = await getAxios(`/knowledge/kbLabelCategory/page?current=${current.value}&size=${pageSize.value}`)
		total.value = +res.total
		tableData.value = res.records
	} else if (navIndex.value == 0 && classification.value) {
		const res = await getAxios(
			`/knowledge/kbLabelCategory/showLabel?ctId=${classifyId.value}&current=${current.value}&size=${pageSize.value}`
		)
		total.value = +res.total
		tableData.value = res.records
	} else {
		selectList.value = []
		if (navIndex.value == 1) {
			status.value = 1
		} else if (navIndex.value == 2) {
			status.value = 3
		}
		await getModelLabel(current.modelValue)
		labelName.value = ""
	}
}
const resetting = async () => {
	search.labelName = ""
	selectList.value = []
	labelName.value = ""
	if (navIndex.value == 0 && !classification.value) {
		lableList()
	} else if (navIndex.value == 0 && classification.value) {
		const res = await getAxios(
			`/knowledge/kbLabelCategory/showLabel?ctId=${classifyId.value}&current=1&size=${pageSize.value}`
		)
		total.value = +res.total
		tableData.value = res.records
	} else {
		getModelLabel()
	}
}
//新增
const add = () => {
	visibleListTitle.value = "新增标签"
	fabu.value = false
	visible.value = true
	tagWeightIf.value = true
	visibleList.value = [
		{
			name: "",
			sort: 1,
			status: status.value,
		},
	]
}
//删除标签分类
const delClassification = async val => {
	ElMessageBox.confirm("是否确认删除", "提示", {
		confirmButtonText: "确定",
		cancelButtonText: "取消",
		type: "warning",
	}).then(async () => {
		try {
			await postAxios(`/knowledge/kbLabelCategory/delete?id=${val.id}`)
			ElMessage.success("删除成功")
			lableList()
		} catch (error) {
			ElMessage.error(error)
		}
	})
}
const addClassification = () => {
	visibleClassification.value = true
	classificationTitle.value = "新增标签分类"
}
const sub = async () => {
	if (fabu.value) {
		return
	}
	fabu.value = true
	if (tagWeightIf.value) {
		if (visibleList.value.some(item => item.name == "")) {
			ElMessage.error("标签名称不能为空")
			fabu.value = false
			return
		}

		const names = new Set(visibleList.value.map(item => item.name))
		if (names.size != visibleList.value.length) {
			ElMessage.error("标签名称不能重复")
			fabu.value = false
			return
		}
		try {
			if (navIndex.value == 0) {
				await postAxios("/knowledge/kbLabelCategory/saveLabel", {
					ctId: classifyId.value,
					labels: visibleList.value.map(item => ({
						name: item.name,
						sort: item.sort,
					})),
				})
				const res = await getAxios(
					`/knowledge/kbLabelCategory/showLabel?ctId=${classifyId.value}&current=1&size=${pageSize.value}`
				)
				total.value = +res.total
				tableData.value = res.records
			} else {
				current.value = 1
				await postAxios("/knowledge/kbModelLabel/save", visibleList.value)
				getModelLabel()
			}
			visibleList.value = [
				{
					name: "",
					sort: 1,
					status: status.value,
				},
			]
			visible.value = false
			ElMessage.success("保存成功")
		} catch (error) {
			ElMessageBox.alert(error, "提示", { type: "warning" })
		} finally {
			fabu.value = false
		}
		return
	}
	try {
		await postAxios("/knowledge/kbModelLabel/edit", visibleList.value[0])
		visible.value = false
		ElMessage.success("修改成功")
		const res = await getAxios(
			`/knowledge/kbLabelCategory/showLabel?ctId=${classifyId.value}&current=1&size=${pageSize.value}`
		)
		total.value = +res.total
		tableData.value = res.records
	} catch (error) {
		ElMessageBox.alert(error, "提示", { type: "warning" })
	} finally {
		fabu.value = false
	}
}
const subClassificationList = async () => {
	let panduan = true
	visibleClassificationList.value.forEach(item => {
		if (item.name == "") {
			panduan = false
		}
	})
	if (panduan) {
		try {
			if (classificationTitle.value == "编辑标签分类") {
				await postAxios(`/knowledge/kbLabelCategory/edit`, visibleClassificationList.value[0])
				ElMessage.success("编辑成功")
			} else {
				await postAxios(`/knowledge/kbLabelCategory/save`, visibleClassificationList.value)
				ElMessage.success("保存成功")
			}
			visibleClassificationList.value = [
				{
					name: "",
				},
			]
			visibleClassification.value = false
			lableList()
		} catch (error) {
			ElMessage.error(error)
			// visibleClassification.value = false
			// visibleClassificationList.value = [
			// 	{
			// 		name: "",
			// 	},
			// ]
		}
	} else {
		ElMessage.error("分类名称不能为空")
	}
}
async function getModelLabel(current = 1) {
	const query = {
		current,
		size: pageSize.value,
	}
	if (status.value == 3) {
		query.isDeleted = 1
	} else {
		query.status = status.value
	}

	const res = await getAxios(`/knowledge/kbModelLabel/page`, query)
	total.value = +res.total
	tableData.value = res.records
}
const efficacy = async val => {
	try {
		if (!selectList.value.length) {
			ElMessage.error("请选择标签")
			return
		}

		await postAxios(
			"/knowledge/kbModelLabel/editStatus",
			selectList.value.map(item => {
				return {
					...item,
					isDeleted: val == "2" ? 2 : 1,
				}
			})
		)
		selectList.value = []
		if (val == "2") {
			ElMessage.success("置为生效成功")
		} else {
			ElMessage.success("置为失效成功")
		}
		if (navIndex.value == 0) {
			const res = await getAxios(
				`/knowledge/kbLabelCategory/showLabel?ctId=${classifyId.value}&current=${current.value}&size=${pageSize.value}`
			)
			total.value = +res.total
			tableData.value = res.records
			return
		}
		getModelLabel()
	} catch (error) {
		ElMessage.error(error)
	}
}
const hot = async (row, item) => {
	await postAxios("/knowledge/kbModelLabel/edit", {
		...row,
		hotWord: item,
	})

	row.hotWord = row.hotWord == 1 ? 2 : 1
}

//批量删除
async function delTags() {
	if (!selectList.value.length) {
		return ElMessage.error("请选择标签")
	}
	try {
		await ElMessageBox.confirm("是否确认删除", "提示", {
			confirmButtonText: "确定",
			cancelButtonText: "取消",
			type: "warning",
		})
	} catch (error) {
		return
	}

	try {
		if (navIndex.value == 0) {
			await postAxios(
				`/knowledge/kbLabelCategory/deleteBatch`,
				selectList.value.map(item => item.id)
			)
			lableList()
		} else {
			await postAxios(
				`/knowledge/kbModelLabel/deleteBatch`,
				selectList.value.map(item => item.id)
			)
			const res = await getAxios(
				`/knowledge/kbModelLabel/page?isDeleted=${status.value - 2}&current=${current.value}&size=${
					pageSize.value
				}`
			)
			total.value = +res.total
			tableData.value = res.records
		}
		selectList.value = []
		ElMessage.success("删除成功")
	} catch (error) {
		ElMessage.error(error)
	}
}
async function delTag(val) {
	try {
		await ElMessageBox.confirm("是否确认删除", "提示", {
			confirmButtonText: "确定",
			cancelButtonText: "取消",
			type: "warning",
		})
	} catch (error) {
		return
	}

	try {
		await postAxios(`/knowledge/kbModelLabel/delete?id=${val.id}`)
		await getModelLabel()
		ElMessage.success("删除成功")
	} catch (error) {
		ElMessage.error(error)
	}
}
const classifyId = ref(null)
//单击标签分类
const clickClassify = async val => {
	current.value = 1
	selectList.value = []
	classification.value = true
	labelName.value = ""
	classifyId.value = val.id
	const res = await getAxios(`/knowledge/kbLabelCategory/showLabel?ctId=${val.id}&current=1&size=${pageSize.value}`)
	total.value = +res.total
	tableData.value = res.records
}
const returnClassify = () => {
	current.value = 1
	classification.value = false
	labelName.value = ""
	lableList()
}

const editClassification = async val => {
	classificationTitle.value = "编辑标签分类"
	visibleClassification.value = true
	const res = await getAxios(`/knowledge/kbLabelCategory/info?id=${val.id}`)
	visibleClassificationList.value[0] = res
}

const tagWeight = val => {
	visibleListTitle.value = "修改标签"
	tagWeightIf.value = false
	visible.value = true
	visibleList.value[0] = JSON.parse(JSON.stringify(val))
}
</script>
<style lang="scss" scoped>
@import "/style/basis";
.quanXian {
	background-color: #f8f8f8;
	height: 100%;
	.nav-dis {
		width: 25px;
		padding: 10px 0;
		text-align: center;
		background-color: #2972fa;
		color: #fff;
		display: none;
		position: fixed;
		top: 50;
		left: 0;
		z-index: 999;
		border-radius: 3px;
		@include maxWidth(768) {
			display: block;
		}
	}
	.title-left {
		padding-left: 20px;
		padding-block: 5px;
	}
	.right {
		width: 250px;
		height: 100%;
		overflow-y: scroll;
		border-right: 1px solid #ebeef5;
		@include maxWidth(1400) {
			width: 220px;
		}
		@include maxWidth(1024) {
			width: 200px;
		}
		@include maxWidth(900) {
			width: 170px;
		}
		@include maxWidth(768) {
			display: none;
		}

		.title {
			.ctheme {
				background: #f0f5ff;
			}
		}
	}

	.icon {
		width: 20px;
		margin-bottom: 10px;
	}

	:deep(.cheng-dialog) {
		width: 550px !important;
	}

	:deep(.cheng-dialog .el-dialog__body) {
		padding: 25px !important;
	}

	.left-bottom {
		padding: 20px;

		.table-head3 {
			.primary {
				margin-left: 15px;
			}

			.danger {
				color: #ff952c;
			}
			.box-button-top {
				@include maxWidth(445) {
					margin-top: 2vh;
				}
			}
		}
		.alert {
			width: 200px;
			margin-bottom: 10px;
		}
		.table-head2 {
			border: 1px solid #eceef5;
			height: 50px;
			padding: 0 2%;
		}

		.table-head {
			margin: 20px 0 20px;

			:deep(.el-input) {
				margin-right: 20px;
			}

			.primary {
				width: 90px;
				height: 30px;
				border-radius: 1px;
				margin-right: 20px;
			}
			.primaryW {
				width: 120px;
			}
			.danger {
				width: 90px;
				height: 30px;
				border-radius: 1px;
				margin-right: 12px;
			}
			.danger-del {
				width: 90px;
				height: 30px;
				border-radius: 1px;
				@include maxWidth(406) {
					// margin-left: 0;
					margin-top: 10px;
				}
			}
		}

		:deep(.el-table) {
			border: 1px solid #eceef5;
		}

		:deep(.el-table th.el-table__cell) {
			background-color: #f4f7fa;
		}

		:deep(.el-table .el-table__cell) {
			height: 40px;
			color: #606266;
		}
	}

	.left {
		margin: 25px;
		// height: 100%;
		overflow-y: scroll;
	}
}
.label-icon {
	margin-left: 5px;
	padding-top: 15px;
}
.name {
	margin-right: 10px;
}
.left-bumen {
	@include maxWidth(768) {
		display: none;
	}
}
.table-color {
	:deep(.el-button) {
		&:focus {
			color: #606266;
			background-color: #fff;
		}
	}
}
</style>
